﻿using System.IO;
using ProjScan.Tools;
using UnityEngine;

namespace ProjScan.RecordManager.AssetData
{
    //
    // 摘要:
    //     需要有导入器的资源数据 - Class58
    //
    // 类型参数:
    //   TAsset:
    //
    //   TImporter:
    internal abstract class ImportAssetData<TAsset, TImporter> : AssetDataBase where TAsset : Object where TImporter : Object
    {
        public TAsset asset;

        public TImporter assetImporter;

        internal string fileName;

        public bool noImporter;

        public int assetPathId;

        public string path;

        public string GUID;

        public ImportAssetData(int id)
        {
            noImporter = false;
            assetPathId = id;
        }

        public ImportAssetData(int id, string path, TAsset asset, TImporter importer)
        {
            noImporter = false;
            this.path = path;
            string text = Path.GetFileName(path);
            this.asset = asset;
            fileName = text;
            assetImporter = importer;
            assetPathId = id;
            GUID = ToolsHelper.GetGUID(asset);
        }

        public ImportAssetData(int id, string path, string fileNameWithoutExtension, TAsset asset, TImporter importer)
        {
            noImporter = false;
            this.path = path;
            string str = Path.GetFileName(path);
            this.asset = asset;
            fileName = str + "/" + asset.name;
            assetImporter = importer;
            assetPathId = id;
            GUID = ToolsHelper.GetGUID(asset);
        }

        public override void Reset()
        {
            asset = null;
            assetImporter = null;
        }

        public override string GetAssetPath()
        {
            return path;
        }

        public override string GetFileAssetPath()
        {
            return path;
        }
    }
}
